package com.wanxi.servlet.other;

import com.wanxi.model.other.BrandModel;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Iterator;

import static com.wanxi.servlet.other.ShowServlet.brandModelList;
@WebServlet("/delete1")
public class DeleteServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer id=Integer.parseInt( req.getParameter("brand"));
        System.out.println(req.getMethod());    //输入请求方法
        Iterator iterator=brandModelList.iterator();
        while (iterator.hasNext()){
            BrandModel b=(BrandModel) iterator.next();
            if(b.getId()==id)
                iterator.remove();
        }
        resp.sendRedirect("/show");
    }
}
